package stti.util;

public class Common {

	private static String libreriaPassword = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.";
	
	public static boolean isWindows()
	{
		String os = System.getProperty("os.name").toLowerCase();
		return (os.indexOf("win") >= 0);
	}
	
	public static boolean isLinux()
	{
		String os = System.getProperty("os.name").toLowerCase();
		return (os.indexOf("nix") >= 0);
	}	
	
	public static String createPassword(int largo)
	{
		String clave = "";
		int n;
		for (int i = 0; i < largo; i++)
		{
			n = (int) Math.round(Math.random()*libreriaPassword.length());
			if (n < 0) { n = 0; } 
			if (n >= libreriaPassword.length()) { n = libreriaPassword.length()-1; }
			clave = clave + libreriaPassword.charAt(n);
		}
		
		return clave;
	}
}
